home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / asm / 68Koptims.lha / 68Koptims.txt < prev   
Encoding:
Text File  |  1997-07-20  |  63.5 KB  |  1,317 lines

  1.                           __
  2.                          /_/\__
  3.                          \ \ \ |\
  4.                       ____\ \ \||__
  5.                      / /  \\ \  __/
  6.                     | | /\ \\ \ \
  7.                     | | \/  \\_\/
  8.                  ____\ \  /\ |
  9.                 / /  \\ \ \/ |
  10.                | | /\/_\_\__/
  11.                | | \/  \
  12.             ____\ \  /\ |
  13.            / /  \\ \ \/ |          ASP68K PROJECT
  14.           /_/ /\ |\_\__/
  15.           \ \ \/ |              Sixth Edition
  16.        ____\ \  /
  17.       / /  \\ \ \            by Michael Glew
  18.      | | /\/_\ \ \           mglew@laurel.ocs.mq.edu.au
  19.      | | \/  \\_\/           Technophilia BBS +61-2-8073563
  20.   ____\_\__/\ |
  21.  / /  \ /_/\/ |           January 1994
  22. | | /\ \\_\__/
  23. | | \/  \
  24.  \ \  /\ \
  25.   \ \ \_\/
  26.    \ \ \
  27.     \_\/
  28.  
  29.  
  30. ---------------------------------------------------------------------------
  31.                           C O N T R I B U T O R S
  32. ---------------------------------------------------------------------------
  33.  
  34.  
  35. Erik Bakke, Robert Barton, Bernd Blank, Kasimir Blomstedt, Frans Bouma,
  36. David Carson, Nicolas Dade, Aaron Digulla, Irmen de Jong, Andy Duplain,
  37. Denis Duplan, Steven Eker, Calle Englund, Alexander Fritsch, Charlie Gibbs,
  38. Kurt Haenen, Jon Hudson, Kjetil Jacobsen, Olav Kalgraf, Makoto Kamada,
  39. Markku Kolkka, John Lane, Jonathan Mahaffy, Dave Mc Mahan, Lindsay Meek,
  40. Walter Misar, Boerge Noest, Gunnar Rxnning, Jay Scott, Olaf Seibert,
  41. Peter Simons.
  42.  
  43.  
  44. ---------------------------------------------------------------------------
  45.                           I N T R O D U C T I O N
  46. ---------------------------------------------------------------------------
  47.  
  48.  
  49. A while back, I was quite interested to find that there was an electronic
  50. magazine called "howtocode" that included lots of interesting hints and
  51. tips of coding.  In the fifth edition, there was a list of optimizations
  52. that really got be thinking.  "What if there was a proggy that you could
  53. put an assembler program through, that would speed it up, taking out all
  54. the stupid things output by compilers, and over-tired coders?" 8).  I
  55. started combing the networks, and came across one such program, called
  56. the "SELCO Source Optimizer".  It only had four optimizations, so I set
  57. to writing my own.
  58.  
  59. Step one was to collect as many optimization ideas as I could.  I posted
  60. to Usenet and got an impressive response, and the contributors are listed
  61. above.  I promised a report on the optimizations recieved, and here it
  62. is.  My aim now is to write a program to make these optimizations, and
  63. to distribute it.  Contributers will recieve a copy of the final archive,
  64. to thank them for their time and energy.  Further contributions will be
  65. welcomed, so rather than making changes yourself tell me what you want
  66. changed, and i'll distribute it with the next update.
  67.  
  68.  
  69. ---------------------------------------------------------------------------
  70.                                C H A N G E S
  71. ---------------------------------------------------------------------------
  72.  
  73.  
  74. 2nd Edition
  75.  
  76. The second edition incorporated a hell of a lot of corrections.  Double
  77. copies of some optimizations were incorporated in to just one copy, and
  78. a few additions were made.  Sorry that the first edition was not sent
  79. out to all contributors, but I was a tad busy. 8)
  80.  
  81.  
  82. 3rd Edition
  83.  
  84. Due to the distribution of the second edition document, many comments were
  85. recieved and a couple of the "optimizations" were found to be incorrect.
  86. Analysis of the mul/div optimizations ended in a few modifications for
  87. safety.  They still save a huge number of clock cycles, so it is better to
  88. be safe than sorry.
  89.  
  90. Also, I have made it so that the number of words of space saved or
  91. increased is shown.  Space savings are positive, increases are negative.
  92. Zero means no change.
  93.  
  94.  
  95. 4th Edition
  96.  
  97. Some minor changes and additions as well as the addition of columns for
  98. '030 and '040 CPUs - whole new format was required...
  99.  
  100.  
  101. 5th Edition
  102.  
  103. Eric Bakke released his docs on 020+ CPUs and 881/882 FPUs.  I have been
  104. given premission to use these docs to further the capabilities of asp68k.
  105. Thanks Eric...  I really would like to get a hold of the 020,030,040
  106. Programmer Reference Cards or manuals, so if anyone has any copies they
  107. wanna send me, let me know...  Local Motorola Distributers are not too
  108. helpful.
  109.  
  110.  
  111. 6th Edition
  112.  
  113. Aaron Digulla advised that it would be helpful if the optimizations were
  114. sorted somehow.  I will sort by the the first letters of the first line
  115. of the optimizations.  Also a special thanks to Makoto Kamada for his
  116. detailed contributions, without such this text would have died long ago..
  117.  
  118.  
  119. 7th Edition (UNOFFICIAL, but have to be done IMHO)
  120.  
  121. · Added 68060 timings
  122. · Removed "RTD dx" and "ASL #n,az" like instructions, and some other
  123.   useless optimizations.
  124. · Added some tips for 68030/68040/68060 coding
  125.  
  126. As far as I know, 68020 instruction timings are very closed to 68030
  127. instruction timings. Since I'm not 100% sure about that, I leave the
  128. 68020 column empty...
  129.  
  130. ---------------------------------------------------------------------------
  131.                          O P T I M I Z A T I O N S
  132. ---------------------------------------------------------------------------
  133.  
  134.  
  135. Note:-
  136.  
  137.     m?      = memory operand
  138.     dx      = data register
  139.     ds      = data register (scratch)
  140.     ax      = address register
  141.     rx      = either a data or address register
  142.     #n      = immediate operand
  143.     ??,?1,?2= address label
  144.     *       = anything
  145.     .x      = any size
  146.     b<cc>   = branch commands
  147.  
  148.     Opt     = optimization
  149.     Notes   = notes about where optimization is valid, and misc notes
  150.     Speed   = are clock periods saved? ("Y" = yes
  151.                                         "y" = in some cases
  152.                                         "N" = no
  153.                                         "*" = increase
  154.                                         "-" = cannot be used on this cpu
  155.                                         "!" = must be used on this cpu
  156.     Size    = how many bytes are saved?
  157.  
  158. -----------------------------------------------------------------
  159. Opt                                            Speed         Size
  160.                                      000 010 020 030 040 060
  161. ------------------------------------+---+---+---+---+---+---+----
  162. * ??* -> * n(pc)*                   | Y | Y | ? | N | * | N | 2
  163. ------------------------------------+---+---+---+---+---+---+----
  164.  n = ??-pc, n < 32768
  165. ------------------------------------+---+---+---+---+---+---+----
  166. *0(ax)* -> *(ax)*                   | Y | Y | ? | y | y | y | 2
  167. ------------------------------------+---+---+---+---+---+---+----
  168. add*.x #0,dx -> tst.x dx            | Y | Y | ? | Y | N | N | 2/4
  169. ------------------------------------+---+---+---+---+---+---+----
  170. add.x #n,* -> addq.x #n,*           | Y | Y | ? | Y | y | y | 2/4
  171. ------------------------------------+---+---+---+---+---+---+----
  172.  if 1 <= n <= 8
  173. ------------------------------------+---+---+---+---+---+---+----
  174. add.x #n,* -> subq.x #-n,*          | Y | Y | ? | Y | N | N | 2/4
  175. ------------------------------------+---+---+---+---+---+---+----
  176.  -8 <= n <= -1
  177. ------------------------------------+---+---+---+---+---+---+----
  178. add.x #n,ax -> lea n(ax),ax         | Y | Y | ? | y | * | N | 0/2
  179. ------------------------------------+---+---+---+---+---+---+----
  180.  -32767 <= n <= -9, 9 <= n <= 32767
  181. ------------------------------------+---+---+---+---+---+---+----
  182. addq.l #n,ax -> addq.w #n,ax        | Y | Y | ? | N | N | N | 0
  183. ------------------------------------+---+---+---+---+---+---+----
  184. addq.l #n,ry -> add.l #(n+m),ry     | Y | Y | ? | Y | * | * |-2
  185. addq.l #m,ry                        |   |   |   |   |   |   |
  186. ------------------------------------+---+---+---+---+---+---+----
  187. addq.x #2,ax   -> move.w *,(ax)     | Y | Y | ? | Y | Y | Y | 2
  188. move.w *,-(ax)                      |   |   |   |   |   |   |
  189. ------------------------------------+---+---+---+---+---+---+----
  190.  .x is .w or .l
  191. ------------------------------------+---+---+---+---+---+---+----
  192. addq.x #4,ax   -> move.l *,(ax)     | Y | Y | ? | Y | Y | Y | 2
  193. move.l *,-(ax)                      |   |   |   |   |   |   |
  194. ------------------------------------+---+---+---+---+---+---+----
  195.  .x is .w or .l
  196. ------------------------------------+---+---+---+---+---+---+----
  197. addq.x #6,ax    -> move.w *1,4(ax)  | Y | Y | ? | Y | y | y | 0
  198. move.w *1,-(ax)    move.l *2,(ax)   |   |   |   |   |   |   |
  199. move.l *2,-(ax)                     |   |   |   |   |   |   |
  200. ------------------------------------+---+---+---+---+---+---+----
  201.  .x is .w or .l
  202.  *1 and *2 do not contain ax
  203. ------------------------------------+---+---+---+---+---+---+----
  204. addq.x #6,ax    -> move.l *1,2(ax)  | Y | Y | ? | Y | y | y | 0
  205. move.l *1,-(ax)    move.w *2,(ax)   |   |   |   |   |   |   |
  206. move.w *2,-(ax)                     |   |   |   |   |   |   |
  207. ------------------------------------+---+---+---+---+---+---+----
  208.  .x is .w or .l
  209.  *1 and *2 do not contain ax
  210. ------------------------------------+---+---+---+---+---+---+----
  211. addq.x #8,ax    -> move.l *1,4(ax)  | Y | Y | ? | Y | y | y | 0
  212. move.l *1,-(ax)    move.l *2,(ax)   |   |   |   |   |   |   |
  213. move.l *2,-(ax)                     |   |   |   |   |   |   |
  214. ------------------------------------+---+---+---+---+---+---+----
  215.  .x is .w or .l
  216.  *1 and *2 do not contain ax
  217. ------------------------------------+---+---+---+---+---+---+----
  218. addq.x #4,sp -> move.l ax,(sp)      | Y | Y | ? | Y | Y | Y | 2
  219. pea (ax)                            |   |   |   |   |   |   |
  220. ------------------------------------+---+---+---+---+---+---+----
  221.  .x is .w or .l
  222.  ax,ay are not a7(=sp)
  223. ------------------------------------+---+---+---+---+---+---+----
  224. addq.x #6,sp   -> move.w *,4(sp)    | Y | Y | ? | Y | Y | Y | 0
  225. move.w *,-(sp)    move.l ax,(sp)    |   |   |   |   |   |   |
  226. pea (ax)                            |   |   |   |   |   |   |
  227. ------------------------------------+---+---+---+---+---+---+----
  228.  .x is .w or .l
  229.  ax,ay are not a7(=sp)
  230. ------------------------------------+---+---+---+---+---+---+----
  231. addq.x #6,sp   -> move.l ax,2(sp)   | Y | Y | ? | Y | Y | Y | 0
  232. pea (ax)          move.w *,(sp)     |   |   |   |   |   |   |
  233. move.w *,-(sp)                      |   |   |   |   |   |   |
  234. ------------------------------------+---+---+---+---+---+---+----
  235.  .x is .w or .l
  236.  ax,ay are not a7(=sp)
  237. ------------------------------------+---+---+---+---+---+---+----
  238. addq.x #8,sp   -> move.l *,4(sp)    | Y | Y | ? | Y | Y | Y | 0
  239. move.l *,-(sp)    move.l ax,(sp)    |   |   |   |   |   |   |
  240. pea (ax)                            |   |   |   |   |   |   |
  241. ------------------------------------+---+---+---+---+---+---+----
  242.  .x is .w or .l
  243.  ax,ay are not a7(=sp)
  244. ------------------------------------+---+---+---+---+---+---+----
  245. addq.x #8,sp   -> move.l ax,4(sp)   | Y | Y | ? | Y | Y | Y | 0
  246. pea (ax)          move.l *,(sp)     |   |   |   |   |   |   |
  247. move.l *,-(sp)                      |   |   |   |   |   |   |
  248. ------------------------------------+---+---+---+---+---+---+----
  249.  .x is .w or .l
  250.  ax,ay are not a7(=sp)
  251. ------------------------------------+---+---+---+---+---+---+----
  252. addq.x #8,sp -> move.l ax,4(sp)     | Y | Y | ? | Y | Y | Y | 0
  253. pea (ax)        move.l ay,(sp)      |   |   |   |   |   |   |
  254. pea (ay)                            |   |   |   |   |   |   |
  255. ------------------------------------+---+---+---+---+---+---+----
  256.  .x is .w or .l
  257.  ax,ay are not a7(=sp)
  258. ------------------------------------+---+---+---+---+---+---+----
  259. and.l #n,dx -> bclr.l #b,dx         | Y | Y | ? | N | * | N | 2
  260. ------------------------------------+---+---+---+---+---+---+----
  261. not(n) = 2^b (only 1 bit off)
  262. ------------------------------------+---+---+---+---+---+---+----
  263. asl.b #2,dy -> add.b dy,dy          | Y | Y | ? | Y | Y | * |-2
  264.                add.b dy,dy          |   |   |   |   |   |   |
  265. ------------------------------------+---+---+---+---+---+---+----
  266. asl.b #n,dx -> clr.b dx             | Y | Y | ? | Y | Y | N | 0
  267. ------------------------------------+---+---+---+---+---+---+----
  268.  status flags are wrong, n>=8
  269. ------------------------------------+---+---+---+---+---+---+----
  270. asl.l #16,dx -> swap dx             | Y | Y | ? | N | N | * |-2
  271.                 clr.w dx            |   |   |   |   |   |   |
  272. ------------------------------------+---+---+---+---+---+---+----
  273.  status flags are wrong
  274. ------------------------------------+---+---+---+---+---+---+----
  275. asl.l #n,dx -> asl.w #(n-16),dx     | Y | Y | ? | * | * | * |-4
  276.                swap dx              |   |   |   |   |   |   |
  277.                clr.w dx             |   |   |   |   |   |   |
  278. ------------------------------------+---+---+---+---+---+---+----
  279.  status flags are wrong, 16<n<32
  280. ------------------------------------+---+---+---+---+---+---+----
  281. asl.l #n,dx -> moveq #0,dx          | Y | Y | ? | Y | Y | N | 0
  282. ------------------------------------+---+---+---+---+---+---+----
  283.  status flags are wrong, n>=32
  284. ------------------------------------+---+---+---+---+---+---+----
  285. asl.w #2,dy -> add.w dy,dy          | Y | Y | ? | Y | Y | * |-2
  286.                add.w dy,dy          |   |   |   |   |   |   |
  287. ------------------------------------+---+---+---+---+---+---+----
  288. asl.w #n,dx -> clr.w dx             | Y | Y | ? | Y | Y | N | 0
  289. ------------------------------------+---+---+---+---+---+---+----
  290.  status flags are wrong, n>=16
  291. ------------------------------------+---+---+---+---+---+---+----
  292. asl.x #1,dy -> add.x dy,dy          | Y | Y | ? | Y | Y | N | 0
  293. ------------------------------------+---+---+---+---+---+---+----
  294. asr.b #n,dx -> clr.b dx             | Y | Y | ? | Y | Y | N | 0
  295. ------------------------------------+---+---+---+---+---+---+----
  296.  status flags are wrong, n>=8
  297. ------------------------------------+---+---+---+---+---+---+----
  298. asr.l #16,dx -> swap dx             | Y | Y | ? | * | * | * |-2
  299.                 ext.l dx            |   |   |   |   |   |   |
  300. ------------------------------------+---+---+---+---+---+---+----
  301.  status flags are wrong
  302. ------------------------------------+---+---+---+---+---+---+----
  303. asr.l #n,dx -> moveq #0,dx          | Y | Y | ? | Y | Y | N | 0
  304. ------------------------------------+---+---+---+---+---+---+----
  305.  status flags are wrong, n>=32
  306. ------------------------------------+---+---+---+---+---+---+----
  307. asr.l #n,dx -> swap dx              | Y | Y | ? | * | * | * |-4
  308.                asr.w #(n-16),dx     |   |   |   |   |   |   |
  309.                ext.l dx             |   |   |   |   |   |   |
  310. ------------------------------------+---+---+---+---+---+---+----
  311.  status flags are wrong, 16<n<32
  312. ------------------------------------+---+---+---+---+---+---+----
  313. asr.w #n,dx -> clr.w dx             | Y | Y | ? | Y | Y | N | 0
  314. ------------------------------------+---+---+---+---+---+---+----
  315.  status flags are wrong, n>=16
  316. ------------------------------------+---+---+---+---+---+---+----
  317. b<cc>.w ?? -> b<cc>.s ??            | Y | Y | ? | Y | N | N | 2
  318. ------------------------------------+---+---+---+---+---+---+----
  319.  abs(??-pc)<128
  320. ------------------------------------+---+---+---+---+---+---+----
  321. bclr.l #n,dx -> and.w #m,dx         | Y | Y | ? | Y | Y | N | 0
  322. ------------------------------------+---+---+---+---+---+---+----
  323.  0 <= n <= 15, m = 65535-(2^n)
  324.  status flags are wrong
  325. ------------------------------------+---+---+---+---+---+---+----
  326. bra ?? -> (nothing)                 | Y | Y | Y | Y | Y | Y | 2/4
  327. ??        ??                        |   |   |   |   |   |   |
  328. ------------------------------------+---+---+---+---+---+---+----
  329.  remove null branches, but keep the label
  330. ------------------------------------+---+---+---+---+---+---+----
  331. bset.b #7,m? -> tas m?              | y | y | ? | * | * | * | 2
  332. beq ??          bpl ??              |   |   |   |   |   |   |
  333. ------------------------------------+---+---+---+---+---+---+----
  334.  m? must be address allowing read-modify-write transfer.
  335.  Status flags are wrong
  336. ------------------------------------+---+---+---+---+---+---+----
  337. bset.b #7,m? -> tas m?              | y | y | ? | * | * | * | 2
  338. bne ??          bmi ??              |   |   |   |   |   |   |
  339. ------------------------------------+---+---+---+---+---+---+----
  340.  m? must be address allowing read-modify-write transfer.
  341.  Status flags are wrong
  342. ------------------------------------+---+---+---+---+---+---+----
  343. bset.b #7,m? -> tas m?              | y | y | ? | * | * | * | 2
  344. ------------------------------------+---+---+---+---+---+---+----
  345.  m? must be address allowing read-modify-write transfer.
  346.  Status flags are wrong
  347. ------------------------------------+---+---+---+---+---+---+----
  348. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | y | N | 2
  349. beq ??          bpl ??              |   |   |   |   |   |   |
  350. ------------------------------------+---+---+---+---+---+---+----
  351.  status flags are wrong
  352. ------------------------------------+---+---+---+---+---+---+----
  353. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | y | N | 2
  354. bne ??          bmi ??              |   |   |   |   |   |   |
  355. ------------------------------------+---+---+---+---+---+---+----
  356.  status flags are wrong
  357. ------------------------------------+---+---+---+---+---+---+----
  358. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | y | N | 2
  359. ------------------------------------+---+---+---+---+---+---+----
  360.  status flags are wrong
  361. ------------------------------------+---+---+---+---+---+---+----
  362. bset.l #n,dx -> or.w #m,dx          | Y | Y | ? | Y | Y | N | 0
  363. ------------------------------------+---+---+---+---+---+---+----
  364.  0 <= n <= 15, m = 2^n
  365.  status flags are wrong
  366. ------------------------------------+---+---+---+---+---+---+----
  367. bsr ?? -> bra ??                    | Y | Y | ? | Y | Y | Y | 2
  368. rts                                 |   |   |   |   |   |   |
  369. ------------------------------------+---+---+---+---+---+---+----
  370.  different stack depth
  371. ------------------------------------+---+---+---+---+---+---+----
  372. btst.b #7,m? -> tst.b m?            | Y | Y | ? | Y | Y | y | 2
  373. beq ??          bpl ??              |   |   |   |   |   |   |
  374. ------------------------------------+---+---+---+---+---+---+----
  375.  Status flags are wrong.  Not valid for Dn, d16(PC), d8(PC,Xn)
  376.  dest address modes.
  377. ------------------------------------+---+---+---+---+---+---+----
  378. btst.b #7,m? -> tst.b m?            | Y | Y | ? | Y | Y | y | 2
  379. bne ??          bmi ??              |   |   |   |   |   |   |
  380. ------------------------------------+---+---+---+---+---+---+----
  381.  Status flags are wrong.  Not valid for Dn, d16(PC), d8(PC,Xn)
  382.  dest address modes.
  383. ------------------------------------+---+---+---+---+---+---+----
  384. btst.l #7,dx -> tst.b dx            | Y | Y | ? | Y | N | N | 2
  385. beq ??          bpl ??              |   |   |   |   |   |   |
  386. ------------------------------------+---+---+---+---+---+---+----
  387.  Status flags are wrong.
  388. ------------------------------------+---+---+---+---+---+---+----
  389. btst.l #7,dx -> tst.b dx            | Y | Y | ? | Y | N | N | 2
  390. bne ??          bmi ??              |   |   |   |   |   |   |
  391. ------------------------------------+---+---+---+---+---+---+----
  392.  Status flags are wrong.
  393. ------------------------------------+---+---+---+---+---+---+----
  394. btst.l #15,dx -> tst.w dx           | Y | Y | ? | Y | N | N | 2
  395. beq ??           bpl ??             |   |   |   |   |   |   |
  396. ------------------------------------+---+---+---+---+---+---+----
  397.  Status flags are wrong.
  398. ------------------------------------+---+---+---+---+---+---+----
  399. btst.l #15,dx -> tst.w dx           | Y | Y | ? | Y | N | N | 2
  400. bne ??           bmi ??             |   |   |   |   |   |   |
  401. ------------------------------------+---+---+---+---+---+---+----
  402.  Status flags are wrong.
  403. ------------------------------------+---+---+---+---+---+---+----
  404. btst.l #31,dx -> tst.l dx           | Y | Y | ? | Y | N | N | 2
  405. beq ??           bpl ??             |   |   |   |   |   |   |
  406. ------------------------------------+---+---+---+---+---+---+----
  407.  Status flags are wrong.
  408. ------------------------------------+---+---+---+---+---+---+----
  409. btst.l #31,dx -> tst.l dx           | Y | Y | ? | Y | N | N | 2
  410. bne ??           bmi ??             |   |   |   |   |   |   |
  411. ------------------------------------+---+---+---+---+---+---+----
  412.  status flags are wrong
  413. ------------------------------------+---+---+---+---+---+---+----
  414. clr.b mn   -> clr.w mn              | Y | Y | ? | Y | Y | Y |2/4/6
  415. clr.b mn+1                          |   |   |   |   |   |   |
  416. ------------------------------------+---+---+---+---+---+---+----
  417.  best if mn is longword aligned
  418. ------------------------------------+---+---+---+---+---+---+----
  419. clr.l dx -> moveq #0,dx             | Y | Y | ? | N | N | N | 0
  420. ------------------------------------+---+---+---+---+---+---+----
  421. clr.w mn   -> clr.l mn              | Y | Y | ? | Y | Y | Y |2/4/6
  422. clr.w mn+2                          |   |   |   |   |   |   |
  423. ------------------------------------+---+---+---+---+---+---+----
  424.  best if mn is longword aligned
  425. ------------------------------------+---+---+---+---+---+---+----
  426. clr.x -(ax) -> move.x ds,-(ax)      | Y | Y | ? | Y | N | N | 0
  427. ------------------------------------+---+---+---+---+---+---+----
  428.  ds must equal zero
  429. ------------------------------------+---+---+---+---+---+---+----
  430. clr.x n(ax,rx) -> move.x ds,n(ax,rx)| Y | Y | ? | Y | N | N | 0
  431. ------------------------------------+---+---+---+---+---+---+----
  432.  ds must equal zero
  433. ------------------------------------+---+---+---+---+---+---+----
  434. cmp.x #0,ax -> move.x ax,ds         | Y | Y | ? | Y | N | N | 2/4
  435. ------------------------------------+---+---+---+---+---+---+----
  436.  move ax to scratch register
  437. ------------------------------------+---+---+---+---+---+---+----
  438. cmp.x #0,ax -> tst.x ax             | - | - | ? | Y | N | N | ?
  439. ------------------------------------+---+---+---+---+---+---+----
  440. for .w and .l
  441. ------------------------------------+---+---+---+---+---+---+----
  442. cmp.x #0,dx -> tst.x dx             | Y | Y | ? | N | N | N | 2/4
  443. ------------------------------------+---+---+---+---+---+---+----
  444. cmp.x #0,m? -> tst.x m?             | Y | Y | ? | Y | Y | Y | 2/4
  445. ------------------------------------+---+---+---+---+---+---+----
  446. may not be legal on some early '000 CPUs
  447. ------------------------------------+---+---+---+---+---+---+----
  448. divu.l #n,dx -> lsr.l #m,dx         | ! | ! | ? | ! | ! | ! | 4
  449. ------------------------------------+---+---+---+---+---+---+----
  450.  n is 2^m, 1 <= m <= 8
  451. ------------------------------------+---+---+---+---+---+---+----
  452. divu.l #n,dx -> moveq #0,dx         | ! | ! | ? | ! | ! | ! | 4
  453. ------------------------------------+---+---+---+---+---+---+----
  454.  n is 2^m, m>=32
  455. ------------------------------------+---+---+---+---+---+---+----
  456. divu.l #n,dx -> moveq #m,ds         | ! | ! | ? | ! | ! | ! | 2
  457.                 lsr.l ds,dx         |   |   |   |   |   |   |
  458. ------------------------------------+---+---+---+---+---+---+----
  459.  n is 2^m, 8<m<32
  460. ------------------------------------+---+---+---+---+---+---+----
  461. divu.w #n,dx -> lsr.l #m,dx         | Y | Y | ? | ! | ! | ! | 2
  462. ------------------------------------+---+---+---+---+---+---+----
  463.  n is 2^m, 1 <= m <= 8, ignore remainder
  464. ------------------------------------+---+---+---+---+---+---+----
  465. divu.w #n,dx -> moveq #0,dx         | Y | Y | ? | ! | ! | ! | 2
  466. ------------------------------------+---+---+---+---+---+---+----
  467.  n is 2^m, m>=32
  468. ------------------------------------+---+---+---+---+---+---+----
  469. divu.w #n,dx -> moveq #m,ds         | Y | Y | ? | ! | ! | ! | 0
  470.                 lsr.l ds,dx         |   |   |   |   |   |   |
  471. ------------------------------------+---+---+---+---+---+---+----
  472.  n is 2^m, 8<m<32, ignore remainder
  473. ------------------------------------+---+---+---+---+---+---+----
  474. eor.x #-1,* -> not.x *              | Y | Y | ? | Y | N | N | 2/4
  475. ------------------------------------+---+---+---+---+---+---+----
  476. ext.w dx -> extb.l dx               | - | - | ? | ? | Y | Y | 2
  477. ext.l dx                            |   |   |   |   |   |   |
  478. ------------------------------------+---+---+---+---+---+---+----
  479. jmp ?? -> bra.w ??                  | Y | Y | ? | y | Y | y | 2
  480. ------------------------------------+---+---+---+---+---+---+----
  481.  abs(??-pc) < 32768, same section
  482. ------------------------------------+---+---+---+---+---+---+----
  483. jsr * -> jmp *                      | Y | Y | ? | Y | Y | Y | 2
  484. rts                                 |   |   |   |   |   |   |
  485. ------------------------------------+---+---+---+---+---+---+----
  486.  different stack depth
  487. ------------------------------------+---+---+---+---+---+---+----
  488. jsr ?1 -> pea ?2                    | y | y | ? | ? | Y | y | 0
  489. jmp ?2    jmp ?1                    |   |   |   |   |   |   |
  490. ------------------------------------+---+---+---+---+---+---+----
  491.  same time if jsr is abs.l (68000/68010)
  492. ------------------------------------+---+---+---+---+---+---+----
  493. jsr ?? -> bsr.w ??                  | Y | Y | ? | y | Y | Y | 2
  494. ------------------------------------+---+---+---+---+---+---+----
  495.  abs(??-pc) < 32768, same section
  496. ------------------------------------+---+---+---+---+---+---+----
  497. lea (ax),ax -> (nothing)            | Y | Y | Y | Y | Y | Y | 2
  498. ------------------------------------+---+---+---+---+---+---+----
  499.  delete
  500. ------------------------------------+---+---+---+---+---+---+----
  501. lea 0.w,ax -> sub.l ax,ax           | Y | Y | ? | Y | * | N | 2
  502. ------------------------------------+---+---+---+---+---+---+----
  503. lea n(ax),ax -> addq.w #n,ax        | Y | Y | ? | Y | Y | N | 2
  504. ------------------------------------+---+---+---+---+---+---+----
  505.  if 1 <= n <= 8
  506. ------------------------------------+---+---+---+---+---+---+----
  507. lea n(ax),ax -> subq.w #-n,ax       | Y | Y | ? | Y | Y | N | 2
  508. ------------------------------------+---+---+---+---+---+---+----
  509.  if -8 <= n <= -1
  510. ------------------------------------+---+---+---+---+---+---+----
  511. lsl.b #2,dy -> add.b dy,dy          | Y | Y | ? | Y | N | * |-2
  512.                add.b dy,dy          |   |   |   |   |   |   |
  513. ------------------------------------+---+---+---+---+---+---+----
  514. lsl.b #n,dx -> clr.b dx             | Y | Y | ? | Y | Y | N | 0
  515. ------------------------------------+---+---+---+---+---+---+----
  516.  status flags are wrong, n>=8
  517. ------------------------------------+---+---+---+---+---+---+----
  518. lsl.l #16,dx -> swap dx             | Y | Y | ? | N | * | * |-2
  519.                 clr.w dx            |   |   |   |   |   |   |
  520. ------------------------------------+---+---+---+---+---+---+----
  521.  status flags are wrong
  522. ------------------------------------+---+---+---+---+---+---+----
  523. lsl.l #n,dx -> lsl.w #(n-16),dx     | Y | Y | ? | * | * | * |-4
  524.                swap dx              |   |   |   |   |   |   |
  525.                clr.w dx             |   |   |   |   |   |   |
  526. ------------------------------------+---+---+---+---+---+---+----
  527.  status flags are wrong, 16<n<32
  528. ------------------------------------+---+---+---+---+---+---+----
  529. lsl.l #n,dx -> moveq #0,dx          | Y | Y | ? | Y | Y | N | 0
  530. ------------------------------------+---+---+---+---+---+---+----
  531.  status flags are wrong, n>=32
  532. ------------------------------------+---+---+---+---+---+---+----
  533. lsl.w #2,dy -> add.w dy,dy          | Y | Y | ? | Y | N | * |-2
  534.                add.w dy,dy          |   |   |   |   |   |   |
  535. ------------------------------------+---+---+---+---+---+---+----
  536. lsl.w #n,dx -> clr.w dx             | Y | Y | ? | Y | Y | N | 0
  537. ------------------------------------+---+---+---+---+---+---+----
  538.  status flags are wrong, n>=16
  539. ------------------------------------+---+---+---+---+---+---+----
  540. lsl.x #1,dy -> add.x dy,dy          | Y | Y | ? | Y | Y | N | 0
  541. ------------------------------------+---+---+---+---+---+---+----
  542. lsr.b #n,dx -> clr.b dx             | Y | Y | ? | Y | Y | N | 0
  543. ------------------------------------+---+---+---+---+---+---+----
  544.  status flags are wrong, n>=8
  545. ------------------------------------+---+---+---+---+---+---+----
  546. lsr.l #16,dx -> clr.w dx            | Y | Y | ? | Y | N | * |-2
  547.                 swap dx             |   |   |   |   |   |   |
  548. ------------------------------------+---+---+---+---+---+---+----
  549.  status flags are wrong
  550. ------------------------------------+---+---+---+---+---+---+----
  551. lsr.l #n,dx -> clr.w dx             | Y | Y | ? | * | * | * |-4
  552.                swap dx              |   |   |   |   |   |   |
  553.                lsr.w #(n-16),dx     |   |   |   |   |   |   |
  554. ------------------------------------+---+---+---+---+---+---+----
  555.  status flags are wrong, 16<n<32
  556. ------------------------------------+---+---+---+---+---+---+----
  557. lsr.l #n,dx -> moveq #0,dx          | Y | Y | ? | Y | Y | N | 0
  558. ------------------------------------+---+---+---+---+---+---+----
  559.  status flags are wrong, n>=32
  560. ------------------------------------+---+---+---+---+---+---+----
  561. lsr.w #n,dx -> clr.w dx             | Y | Y | ? | Y | Y | N | 0
  562. ------------------------------------+---+---+---+---+---+---+----
  563.  status flags are wrong, n>=16
  564. ------------------------------------+---+---+---+---+---+---+----
  565. move.b #-1,(ax) -> st (ax)          | Y | Y | ? | * | * | N | 2
  566. ------------------------------------+---+---+---+---+---+---+----
  567.  status flags are wrong
  568. ------------------------------------+---+---+---+---+---+---+----
  569. move.b #-1,(ax)+ -> st (ax)+        | N | N | ? | * |Y/*| N | 2
  570. ------------------------------------+---+---+---+---+---+---+----
  571.  status flags are wrong
  572. ------------------------------------+---+---+---+---+---+---+----
  573. move.b #-1,-(ax) -> st -(ax)        | N | N | ? | * |Y/*| N | 2
  574. ------------------------------------+---+---+---+---+---+---+----
  575.  status flags are wrong
  576. ------------------------------------+---+---+---+---+---+---+----
  577. move.b #-1,?? -> st ??              | Y | Y | ? | * |Y/*| Y | 2
  578. ------------------------------------+---+---+---+---+---+---+----
  579.  status flags are wrong
  580. ------------------------------------+---+---+---+---+---+---+----
  581. move.b #-1,dx -> st dx              | Y | Y | ? | N | * | N | 2
  582. ------------------------------------+---+---+---+---+---+---+----
  583.  status flags are wrong
  584. ------------------------------------+---+---+---+---+---+---+----
  585. move.b #-1,n(ax) -> st n(ax)        | Y | Y | ? | * |Y/N| Y | 2
  586. ------------------------------------+---+---+---+---+---+---+----
  587.  status flags are wrong
  588. ------------------------------------+---+---+---+---+---+---+----
  589. move.b #-1,n(ax,rx) -> st n(ax,rx)  | Y | Y | ? | * | * | Y | 2
  590. ------------------------------------+---+---+---+---+---+---+----
  591.  status flags are wrong
  592. ------------------------------------+---+---+---+---+---+---+----
  593. move.b #x,mn   -> move.w #xy,mn     | Y | Y | ? | Y | Y | Y |4/6/8
  594. move.b #y,mn+1                      |   |   |   |   |   |   |
  595. ------------------------------------+---+---+---+---+---+---+----
  596.  best if mn is longword aligned
  597. ------------------------------------+---+---+---+---+---+---+----
  598. move.l #n,-(sp) -> pea n.w          | Y | Y | ? | N | N | N | 2
  599. ------------------------------------+---+---+---+---+---+---+----
  600.  -32767 <= n <= 32767
  601. ------------------------------------+---+---+---+---+---+---+----
  602. move.l #n,ax -> move.w #n,ax        | Y | Y | ? | Y | N | N | 2
  603. ------------------------------------+---+---+---+---+---+---+----
  604.  -32767 <= n <= 32767
  605. ------------------------------------+---+---+---+---+---+---+----
  606. move.l #n,dx -> moveq #-128,dx      | Y | Y | ? | Y | * | * | 2
  607.                 subq.l #n+128,dx    |   |   |   |   |   |   |
  608. ------------------------------------+---+---+---+---+---+---+----
  609.  -136 <= n <= -129
  610. ------------------------------------+---+---+---+---+---+---+----
  611. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | Y | * | * | 2
  612.                 not.b dx            |   |   |   |   |   |   |
  613. ------------------------------------+---+---+---+---+---+---+----
  614.  128 <= n <= 255, m = 255-n
  615. ------------------------------------+---+---+---+---+---+---+----
  616. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | Y | * | * | 2
  617.                 not.w dx            |   |   |   |   |   |   |
  618.                                     |   |   |   |   |   |   |
  619. ------------------------------------+---+---+---+---+---+---+----
  620.  65534 <= n <= 65408 or -65409 <= n <= -65536, m = 65535-abs(n)
  621. ------------------------------------+---+---+---+---+---+---+----
  622. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | N | * | * | 2
  623.                 swap dx             |   |   |   |   |   |   |
  624.                                     |   |   |   |   |   |   |
  625. ------------------------------------+---+---+---+---+---+---+----
  626.  -8323073 <= n <= -65537 or 4096 <= n <= 8323072, n = m*65536
  627. ------------------------------------+---+---+---+---+---+---+----
  628. move.l #n,dx -> moveq #n,dx         | Y | Y | ? | Y | N | N | 4
  629. ------------------------------------+---+---+---+---+---+---+----
  630.  if -128 <= n <= 127
  631. ------------------------------------+---+---+---+---+---+---+----
  632. move.l #n,dx -> moveq #y,dx         | * | * | ? | N | * | * | 2
  633.                 lsl.l #z,dx         |   |   |   |   |   |   |
  634. ------------------------------------+---+---+---+---+---+---+----
  635.  n = y * 2^z
  636. ------------------------------------+---+---+---+---+---+---+----
  637. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | Y | * | * | 2
  638.                 add.b dx,dx         |   |   |   |   |   |   |
  639. ------------------------------------+---+---+---+---+---+---+----
  640.  (128 <= n <= 254 or -256 <= n <= -130) and n is even, m = n/2
  641. ------------------------------------+---+---+---+---+---+---+----
  642. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | * | * | * | 2
  643.                 bchg.l dx,dx        |   |   |   |   |   |   |
  644. ------------------------------------+---+---+---+---+---+---+----
  645.  n = -32881 -> m = -113
  646.  n = -32849 -> m = -81
  647.  n = -32817 -> m = -49
  648.  n = -32785 -> m = -17
  649.  n = -16498 -> m = -114
  650.  n = -16466 -> m = -82
  651.  n = -16434 -> m = -50
  652.  n = -16402 -> m = -18
  653.  n = -8307 -> m = -115
  654.  n = -8275 -> m = -83
  655.  n = -8243 -> m = -51
  656.  n = -8211 -> m = -19
  657.  n = -4212 -> m = -116
  658.  n = -4180 -> m = -84
  659.  n = -4148 -> m = -52
  660.  n = -4116 -> m = -20
  661.  n = -2165 -> m = -117
  662.  n = -2133 -> m = -85
  663.  n = -2101 -> m = -53
  664.  n = -2069 -> m = -21
  665.  n = -1142 -> m = -118
  666.  n = -1110 -> m = -86
  667.  n = -1078 -> m = -54
  668.  n = -1046 -> m = -22
  669.  n = -631 -> m = -119
  670.  n = -599 -> m = -87
  671.  n = -567 -> m = -55
  672.  n = -535 -> m = -23
  673.  n = -376 -> m = -120
  674.  n = -344 -> m = -88
  675.  n = -312 -> m = -56
  676.  n = -280 -> m = -24
  677.  n = 264 -> m = 8
  678.  n = 296 -> m = 40
  679.  n = 328 -> m = 72
  680.  n = 360 -> m = 104
  681.  n = 521 -> m = 9
  682.  n = 553 -> m = 41
  683.  n = 585 -> m = 73
  684.  n = 617 -> m = 105
  685.  n = 1034 -> m = 10
  686.  n = 1066 -> m = 42
  687.  n = 1098 -> m = 74
  688.  n = 1130 -> m = 106
  689.  n = 2059 -> m = 11
  690.  n = 2091 -> m = 43
  691.  n = 2123 -> m = 75
  692.  n = 2155 -> m = 107
  693.  n = 4108 -> m = 12
  694.  n = 4140 -> m = 44
  695.  n = 4172 -> m = 76
  696.  n = 4204 -> m = 108
  697.  n = 8205 -> m = 13
  698.  n = 8237 -> m = 45
  699.  n = 8269 -> m = 77
  700.  n = 8301 -> m = 109
  701.  n = 16398 -> m = 14
  702.  n = 16430 -> m = 46
  703.  n = 16462 -> m = 78
  704.  n = 16494 -> m = 110
  705.  n = 32783 -> m = 15
  706.  n = 32815 -> m = 47
  707.  n = 32847 -> m = 79
  708.  n = 32879 -> m = 111
  709. ------------------------------------+---+---+---+---+---+---+----
  710. move.l #n,dx -> moveq #m,dx         | N | N | ? | * | * | * | 2
  711.                 bchg.l dx,dx        |   |   |   |   |   |   |
  712. ------------------------------------+---+---+---+---+---+---+----
  713.  n = -2147483617 -> m = 31
  714.  n = -2147483585 -> m = 63
  715.  n = -2147483553 -> m = 95
  716.  n = -2147483521 -> m = 127
  717.  n = -1073741922 -> m = -98
  718.  n = -1073741890 -> m = -66
  719.  n = -1073741858 -> m = -34
  720.  n = -1073741826 -> m = -2
  721.  n = -536871011 -> m = -99
  722.  n = -536870979 -> m = -67
  723.  n = -536870947 -> m = -35
  724.  n = -536870915 -> m = -3
  725.  n = -268435556 -> m = -100
  726.  n = -268435524 -> m = -68
  727.  n = -268435492 -> m = -36
  728.  n = -268435460 -> m = -4
  729.  n = -134217829 -> m = -101
  730.  n = -134217797 -> m = -69
  731.  n = -134217765 -> m = -37
  732.  n = -134217733 -> m = -5
  733.  n = -67108966 -> m = -102
  734.  n = -67108934 -> m = -70
  735.  n = -67108902 -> m = -38
  736.  n = -67108870 -> m = -6
  737.  n = -33554535 -> m = -103
  738.  n = -33554503 -> m = -71
  739.  n = -33554471 -> m = -39
  740.  n = -33554439 -> m = -7
  741.  n = -16777320 -> m = -104
  742.  n = -16777288 -> m = -72
  743.  n = -16777256 -> m = -40
  744.  n = -16777224 -> m = -8
  745.  n = -8388713 -> m = -105
  746.  n = -8388681 -> m = -73
  747.  n = -8388649 -> m = -41
  748.  n = -8388617 -> m = -9
  749.  n = -4194410 -> m = -106
  750.  n = -4194378 -> m = -74
  751.  n = -4194346 -> m = -42
  752.  n = -4194314 -> m = -10
  753.  n = -2097259 -> m = -107
  754.  n = -2097227 -> m = -75
  755.  n = -2097195 -> m = -43
  756.  n = -2097163 -> m = -11
  757.  n = -1048684 -> m = -108
  758.  n = -1048652 -> m = -76
  759.  n = -1048620 -> m = -44
  760.  n = -1048588 -> m = -12
  761.  n = -524397 -> m = -109
  762.  n = -524365 -> m = -77
  763.  n = -524333 -> m = -45
  764.  n = -524301 -> m = -13
  765.  n = -262254 -> m = -110
  766.  n = -262222 -> m = -78
  767.  n = -262190 -> m = -46
  768.  n = -262158 -> m = -14
  769.  n = -131183 -> m = -111
  770.  n = -131151 -> m = -79
  771.  n = -131119 -> m = -47
  772.  n = -131087 -> m = -15
  773.  n = -65648 -> m = -112
  774.  n = -65616 -> m = -80
  775.  n = -65584 -> m = -48
  776.  n = -65552 -> m = -16
  777.  n = 65552 -> m = 16
  778.  n = 65584 -> m = 48
  779.  n = 65616 -> m = 80
  780.  n = 65648 -> m = 112
  781.  n = 131089 -> m = 17
  782.  n = 131121 -> m = 49
  783.  n = 131153 -> m = 81
  784.  n = 131185 -> m = 113
  785.  n = 262162 -> m = 18
  786.  n = 262194 -> m = 50
  787.  n = 262226 -> m = 82
  788.  n = 262258 -> m = 114
  789.  n = 524307 -> m = 19
  790.  n = 524339 -> m = 51
  791.  n = 524371 -> m = 83
  792.  n = 524403 -> m = 115
  793.  n = 1048596 -> m = 20
  794.  n = 1048628 -> m = 52
  795.  n = 1048660 -> m = 84
  796.  n = 1048692 -> m = 116
  797.  n = 2097173 -> m = 21
  798.  n = 2097205 -> m = 53
  799.  n = 2097237 -> m = 85
  800.  n = 2097269 -> m = 117
  801.  n = 4194326 -> m = 22
  802.  n = 4194358 -> m = 54
  803.  n = 4194390 -> m = 86
  804.  n = 4194422 -> m = 118
  805.  n = 8388631 -> m = 23
  806.  n = 8388663 -> m = 55
  807.  n = 8388695 -> m = 87
  808.  n = 8388727 -> m = 119
  809.  n = 16777240 -> m = 24
  810.  n = 16777272 -> m = 56
  811.  n = 16777304 -> m = 88
  812.  n = 16777336 -> m = 120
  813.  n = 33554457 -> m = 25
  814.  n = 33554489 -> m = 57
  815.  n = 33554521 -> m = 89
  816.  n = 33554553 -> m = 121
  817.  n = 67108890 -> m = 26
  818.  n = 67108922 -> m = 58
  819.  n = 67108954 -> m = 90
  820.  n = 67108986 -> m = 122
  821.  n = 134217755 -> m = 27
  822.  n = 134217787 -> m = 59
  823.  n = 134217819 -> m = 91
  824.  n = 134217851 -> m = 123
  825.  n = 268435484 -> m = 28
  826.  n = 268435516 -> m = 60
  827.  n = 268435548 -> m = 92
  828.  n = 268435580 -> m = 124
  829.  n = 536870941 -> m = 29
  830.  n = 536870973 -> m = 61
  831.  n = 536871005 -> m = 93
  832.  n = 536871037 -> m = 125
  833.  n = 1073741854 -> m = 30
  834.  n = 1073741886 -> m = 62
  835.  n = 1073741918 -> m = 94
  836.  n = 1073741950 -> m = 126
  837.  n = 2147483551 -> m = -97
  838.  n = 2147483583 -> m = -65
  839.  n = 2147483615 -> m = -33
  840.  n = 2147483647 -> m = -1
  841. ------------------------------------+---+---+---+---+---+---+----
  842. move.l #n,m? -> moveq  #n,ds        | Y | Y | ? | Y |N/*| y | 2
  843.                 move.l ds,m?        |   |   |   |   |   |   |
  844. ------------------------------------+---+---+---+---+---+---+----
  845.  -128 <= n <= 127
  846. ------------------------------------+---+---+---+---+---+---+----
  847. move.l (ax),ay -> move.x ([ax],n),dz| - | - | ? | * | * | * | 0
  848. move.x n(ay),dz                     |   |   |   |   |   |   |
  849. ------------------------------------+---+---+---+---+---+---+----
  850. move.l (ax),ay -> move.x ([ax]),dz  | - | - | ? | * | * | * | 0
  851. move.x (ay),dz                      |   |   |   |   |   |   |
  852. ------------------------------------+---+---+---+---+---+---+----
  853. move.l (bd.x,ax),dy ->              | - | - | ? | Y | Y | Y | 2
  854.                      move.l bd.x,dy |   |   |   |   |   |   |
  855. ------------------------------------+---+---+---+---+---+---+----
  856. move.l (n.w,ax),dy ->               | N | N | N | N | N | N | 0
  857.                     move.l n(ax),dy |   |   |   |   |   |   |
  858. ------------------------------------+---+---+---+---+---+---+----
  859. move.l (sp),(n,sp) -> rtd #n        | - | - | ? | Y | Y | Y | 6
  860. lea (n,sp),sp                       |   |   |   |   |   |   |
  861. rts                                 |   |   |   |   |   |   |
  862. ------------------------------------+---+---+---+---+---+---+----
  863. move.l 12(ax),12(ay) -> move16      | - | - | - | - | y | ? | 22
  864. move.l 8(ax),8(ay)      (ax)+,(ay)+ |   |   |   |   |   |   |
  865. move.l 4(ax),4(ay)                  |   |   |   |   |   |   |
  866. move.l (ax)+,(ay)+                  |   |   |   |   |   |   |
  867. ------------------------------------+---+---+---+---+---+---+----
  868. move.l ax,-(sp) -> link ax,#n       | Y | Y | ? | Y | N | Y | 4
  869. move.l sp,ax                        |   |   |   |   |   |   |
  870. add.w #n,sp                         |   |   |   |   |   |   |
  871. ------------------------------------+---+---+---+---+---+---+----
  872.  -32767 <= n <= 32767
  873. ------------------------------------+---+---+---+---+---+---+----
  874. move.l ax,-(sp) -> pea -n(ax)       | Y | Y | ? | Y | Y | N | 0/4
  875. sub*.l #n,(sp)                      |   |   |   |   |   |   |
  876. ------------------------------------+---+---+---+---+---+---+----
  877. move.l ax,-(sp) -> pea n(ax)        | Y | Y | ? | Y | Y | N | 0/4
  878. add*.l #n,(sp)                      |   |   |   |   |   |   |
  879. ------------------------------------+---+---+---+---+---+---+----
  880. move.l ax,sp -> unlk ax             | Y | Y | ? | N | y | N | 2
  881. move.l (sp)+,ax                     |   |   |   |   |   |   |
  882. ------------------------------------+---+---+---+---+---+---+----
  883. move.w #x,mn   -> move.l #xy,mn     | Y | Y | ? | Y | Y | Y |2/4/6
  884. move.w #y,mn+2                      |   |   |   |   |   |   |
  885. ------------------------------------+---+---+---+---+---+---+----
  886.  best if mn is longword aligned
  887. ------------------------------------+---+---+---+---+---+---+----
  888. move.x #0,ax -> sub.l ax,ax         | Y | Y | ? | Y | * | N | 2/4
  889. ------------------------------------+---+---+---+---+---+---+----
  890. move.x #n,ax -> lea n,ax            | Y | Y | ? | N | N | N | 0
  891. ------------------------------------+---+---+---+---+---+---+----
  892.  n <> 0
  893. ------------------------------------+---+---+---+---+---+---+----
  894. move.x ax,ay -> lea n(ax),ay        | Y | Y | ? | Y | Y | Y | 2/4
  895. add.x #n,ay                         |   |   |   |   |   |   |
  896. ------------------------------------+---+---+---+---+---+---+----
  897.  -32767 <= n <= 32767
  898. ------------------------------------+---+---+---+---+---+---+----
  899. move.x ax,az -> lea -n(ax,dx),az    | Y | Y | ? | Y | Y | Y | 2
  900. sub.x #n,az                         |   |   |   |   |   |   |
  901. add.x dx,az                         |   |   |   |   |   |   |
  902. ------------------------------------+---+---+---+---+---+---+----
  903.  az=n+ax+dx, n<=32767
  904. ------------------------------------+---+---+---+---+---+---+----
  905. move.x ax,az -> lea n(ax,dx),az     | Y | Y | ? | Y | Y | Y | 2
  906. add.x #n,az                         |   |   |   |   |   |   |
  907. add.x dx,az                         |   |   |   |   |   |   |
  908. ------------------------------------+---+---+---+---+---+---+----
  909.  az=n+ax+dx, n<=32767
  910. ------------------------------------+---+---+---+---+---+---+----
  911. movem.l (ax)+,registers             | * | * | ? | ? | Y | N | *
  912.                  -> move.l (ax)+,ry |   |   |   |   |   |   |
  913.                        for each reg |   |   |   |   |   |   |
  914. ------------------------------------+---+---+---+---+---+---+----
  915. movem.x *,@ -> move.x *,@           | Y | Y | ? | Y | Y | N | 2
  916.                                     |   |   |   |   |   |   |
  917. ------------------------------------+---+---+---+---+---+---+----
  918.  @ = a single register, not (@=dx & .x=.w)
  919. ------------------------------------+---+---+---+---+---+---+----
  920. movem.x @,* -> move.x @,*           | Y | Y | ? | Y | Y | N | 2
  921.                                     |   |   |   |   |   |   |
  922. ------------------------------------+---+---+---+---+---+---+----
  923.  @ = a single register, status flags are wrong
  924. ------------------------------------+---+---+---+---+---+---+----
  925. moveq #n,az -> lea n(ax,ay.l*2),az  | - | - | ? | Y | Y | Y | 4
  926. add.x ay,az                         |   |   |   |   |   |   |
  927. add.x ax,az                         |   |   |   |   |   |   |
  928. add.x ay,az                         |   |   |   |   |   |   |
  929. ------------------------------------+---+---+---+---+---+---+----
  930.  az=n+ax+2*ay, -128<=n<=127
  931. ------------------------------------+---+---+---+---+---+---+----
  932. mul*.l #1,dx -> (nothing)           | ! | ! | ! | ! | ! | Y | 6
  933. ------------------------------------+---+---+---+---+---+---+----
  934.  delete
  935. ------------------------------------+---+---+---+---+---+---+----
  936. mul*.l #10,dx -> add.l dx,dx        | ! | ! | ? | Y | Y | * |-2
  937.                  move.l dx,ds       |   |   |   |   |   |   |
  938.                  asl.l #2,dx        |   |   |   |   |   |   |
  939.                  add.l ds,dx        |   |   |   |   |   |   |
  940. ------------------------------------+---+---+---+---+---+---+----
  941. mul*.l #12,dx -> asl.l #2,dx        | ! | ! | ? | Y | Y | * |-2
  942.                  move.l dx,ds       |   |   |   |   |   |   |
  943.                  add.l dx,dx        |   |   |   |   |   |   |
  944.                  add.l ds,dx        |   |   |   |   |   |   |
  945. ------------------------------------+---+---+---+---+---+---+----
  946. mul*.l #2,dx -> add.l dx,dx         | ! | ! | ? | ! | ! | Y | 4
  947. ------------------------------------+---+---+---+---+---+---+----
  948. mul*.l #3,dx -> move.l dx,ds        | ! | ! | ? | ! | ! | * | 0
  949.                 add.l dx,dx         |   |   |   |   |   |   |
  950.                 add.l ds,dx         |   |   |   |   |   |   |
  951. ------------------------------------+---+---+---+---+---+---+----
  952. mul*.l #5,dx -> move.l dx,ds        | ! | ! | ? | ! | ! | * | 0
  953.                 asl.l #2,dx         |   |   |   |   |   |   |
  954.                 add.l ds,dx         |   |   |   |   |   |   |
  955. ------------------------------------+---+---+---+---+---+---+----
  956. mul*.l #6,dx -> add.l dx,dx         | ! | ! | ? | ! | ! | * |-2
  957.                 move.l dx,ds        |   |   |   |   |   |   |
  958.                 add.l dx,dx         |   |   |   |   |   |   |
  959.                 add.l ds,dx         |   |   |   |   |   |   |
  960. ------------------------------------+---+---+---+---+---+---+----
  961. mul*.l #7,dx -> move.l dx,ds        | ! | ! | ? | ! | ! | * | 0
  962.                 asl.l #3,dx         |   |   |   |   |   |   |
  963.                 sub.l ds,dx         |   |   |   |   |   |   |
  964. ------------------------------------+---+---+---+---+---+---+----
  965. mul*.l #9,dx -> move.l dx,ds        | ! | ! | ? | ! | ! | * | 0
  966.                 asl.l #3,dx         |   |   |   |   |   |   |
  967.                 add.l ds,dx         |   |   |   |   |   |   |
  968. ------------------------------------+---+---+---+---+---+---+----
  969. mul*.l #n,dx -> moveq #m,ds         | ! | ! | ? | ! | ! | N | 2
  970.                 asl.l ds,dx         |   |   |   |   |   |   |
  971. ------------------------------------+---+---+---+---+---+---+----
  972.  n is 2^m, 8<m<14
  973. ------------------------------------+---+---+---+---+---+---+----
  974. muls.l #0,dx -> moveq #0,dx         | ! | ! | ? | ! | ! | Y | 4
  975. ------------------------------------+---+---+---+---+---+---+----
  976. muls.l #n,dx -> asl.l #m,dx         | ! | ! | ? | ! | ! | Y | 4
  977. ------------------------------------+---+---+---+---+---+---+----
  978.  n is 2^m, 1 <= m <= 8
  979. ------------------------------------+---+---+---+---+---+---+----
  980. muls.w #0,dx -> moveq #0,dx         | Y | Y | ? | ! | ! | Y | 2
  981. ------------------------------------+---+---+---+---+---+---+----
  982. muls.w #1,dx -> ext.l dx            | Y | Y | ? | ! | ! | Y | 2
  983. ------------------------------------+---+---+---+---+---+---+----
  984. muls.w #10,dx -> ext.l dx           | Y | Y | ? | ! | ! | * |-6
  985.                  add.l dx,dx        |   |   |   |   |   |   |
  986.                  move.l dx,ds       |   |   |   |   |   |   |
  987.                  asl.l #2,dx        |   |   |   |   |   |   |
  988.                  add.l ds,dx        |   |   |   |   |   |   |
  989. ------------------------------------+---+---+---+---+---+---+----
  990. muls.w #11,dx -> ext.l dx           | Y | Y | ? | ! | ! | * |-8
  991.                  move.l dx,ds       |   |   |   |   |   |   |
  992.                  add.l dx,dx        |   |   |   |   |   |   |
  993.                  add.l dx,ds        |   |   |   |   |   |   |
  994.                  asl.l #3,dx        |   |   |   |   |   |   |
  995.                  add.l ds,dx        |   |   |   |   |   |   |
  996. ------------------------------------+---+---+---+---+---+---+----
  997. muls.w #12,dx -> ext.l dx           | Y | Y | ? | ! | ! | * |-6
  998.                  asl.l #2,dx        |   |   |   |   |   |   |
  999.                  move.l dx,ds       |   |   |   |   |   |   |
  1000.                  add.l dx,dx        |   |   |   |   |   |   |
  1001.                  add.l ds,dx        |   |   |   |   |   |   |
  1002. ------------------------------------+---+---+---+---+---+---+----
  1003. muls.w #2,dx -> ext.l dx            | Y | Y | ? | ! | ! | N | 0
  1004.                 add.l dx,dx         |   |   |   |   |   |   |
  1005. ------------------------------------+---+---+---+---+---+---+----
  1006. muls.w #3,dx -> ext.l dx            | Y | Y | ? | ! | ! | * |-4
  1007.                 move.l dx,ds        |   |   |   |   |   |   |
  1008.                 add.l dx,dx         |   |   |   |   |   |   |
  1009.                 add.l ds,dx         |   |   |   |   |   |   |
  1010. ------------------------------------+---+---+---+---+---+---+----
  1011. muls.w #5,dx -> ext.l dx            | Y | Y | ? | ! | ! | * |-4
  1012.                 move.l dx,ds        |   |   |   |   |   |   |
  1013.                 asl.l #2,dx         |   |   |   |   |   |   |
  1014.                 add.l ds,dx         |   |   |   |   |   |   |
  1015. ------------------------------------+---+---+---+---+---+---+----
  1016. muls.w #6,dx -> ext.l dx            | Y | Y | ? | ! | ! | * |-6
  1017.                 add.l dx,dx         |   |   |   |   |   |   |
  1018.                 move.l dx,ds        |   |   |   |   |   |   |
  1019.                 add.l ds,dx         |   |   |   |   |   |   |
  1020.                 add.l ds,dx         |   |   |   |   |   |   |
  1021. ------------------------------------+---+---+---+---+---+---+----
  1022. muls.w #7,dx -> ext.l dx            | Y | Y | ? | ! | ! | * |-4
  1023.                 move.l dx,ds        |   |   |   |   |   |   |
  1024.                 asl.l #3,dx         |   |   |   |   |   |   |
  1025.                 sub.l ds,dx         |   |   |   |   |   |   |
  1026. ------------------------------------+---+---+---+---+---+---+----
  1027. muls.w #9,dx -> ext.l dx            | Y | Y | ? | ! | ! | * |-4
  1028.                 move.l dx,ds        |   |   |   |   |   |   |
  1029.                 asl.l #3,dx         |   |   |   |   |   |   |
  1030.                 add.l ds,dx         |   |   |   |   |   |   |
  1031. ------------------------------------+---+---+---+---+---+---+----
  1032. muls.w #n,dx -> ext.l dx            | Y | Y | ? | ! | ! | N | 0
  1033.                 asl.l #m,dx         |   |   |   |   |   |   |
  1034. ------------------------------------+---+---+---+---+---+---+----
  1035.  n is 2^m, 1 <= m <= 8
  1036. ------------------------------------+---+---+---+---+---+---+----
  1037. muls.w #n,dx -> moveq #m,ds         | Y | Y | ? | ! | ! | * |-2
  1038.                 ext.l dx            |   |   |   |   |   |   |
  1039.                 asl.l ds,dx         |   |   |   |   |   |   |
  1040. ------------------------------------+---+---+---+---+---+---+----
  1041.  n is 2^m, 8<m<14
  1042. ------------------------------------+---+---+---+---+---+---+----
  1043. muls.w #n,dx -> swap dx             | Y | Y | ? | ! | ! | * |-2
  1044.                 clr.w dx            |   |   |   |   |   |   |
  1045.                 asr.l #(16-m),dx    |   |   |   |   |   |   |
  1046. ------------------------------------+---+---+---+---+---+---+----
  1047.  n is 2^m, 8 <= m <= 15
  1048. ------------------------------------+---+---+---+---+---+---+----
  1049. mulu.l #0,dx -> moveq #0,dx         | ! | ! | ? | ! | ! | Y | 4
  1050. ------------------------------------+---+---+---+---+---+---+----
  1051. mulu.l #n,dx -> lsl.l #m,dx         | ! | ! | ? | ! | ! | Y | 4
  1052. ------------------------------------+---+---+---+---+---+---+----
  1053.  n is 2^m, 1 <= m <= ?
  1054. ------------------------------------+---+---+---+---+---+---+----
  1055. mulu.w #0,dx -> moveq #0,dx         | Y | Y | ? | ! | ! | Y | 2
  1056. ------------------------------------+---+---+---+---+---+---+----
  1057. mulu.w #1,dx -> swap dx             | Y | Y | ? | ! | ! | * |-2
  1058.                 clr.w dx            |   |   |   |   |   |   |
  1059.                 swap dx             |   |   |   |   |   |   |
  1060. ------------------------------------+---+---+---+---+---+---+----
  1061. mulu.w #12,dx -> swap dx            | Y | Y | ? | ! | Y | * |-10
  1062.                  clr.w dx           |   |   |   |   |   |   |
  1063.                  swap dx            |   |   |   |   |   |   |
  1064.                  asl.l #2,dx        |   |   |   |   |   |   |
  1065.                  move.l dx,ds       |   |   |   |   |   |   |
  1066.                  add.l dx,dx        |   |   |   |   |   |   |
  1067.                  add.l ds,dx        |   |   |   |   |   |   |
  1068. ------------------------------------+---+---+---+---+---+---+----
  1069. mulu.w #2,dx -> swap dx             | Y | Y | ? | ! | ! | * |-4
  1070.                 clr.w dx            |   |   |   |   |   |   |
  1071.                 swap dx             |   |   |   |   |   |   |
  1072.                 add.l dx,dx         |   |   |   |   |   |   |
  1073. ------------------------------------+---+---+---+---+---+---+----
  1074. mulu.w #3,dx -> swap dx             | Y | Y | ? | ! | ! | * |-8
  1075.                 clr.w dx            |   |   |   |   |   |   |
  1076.                 swap dx             |   |   |   |   |   |   |
  1077.                 move.l dx,ds        |   |   |   |   |   |   |
  1078.                 add.l dx,dx         |   |   |   |   |   |   |
  1079.                 add.l ds,dx         |   |   |   |   |   |   |
  1080. ------------------------------------+---+---+---+---+---+---+----
  1081. mulu.w #5,dx -> swap dx             | Y | Y | ? | ! | ! | * |-8
  1082.                 clr.w dx            |   |   |   |   |   |   |
  1083.                 swap dx             |   |   |   |   |   |   |
  1084.                 move.l dx,ds        |   |   |   |   |   |   |
  1085.                 asl.l #2,dx         |   |   |   |   |   |   |
  1086.                 add.l ds,dx         |   |   |   |   |   |   |
  1087. ------------------------------------+---+---+---+---+---+---+----
  1088. mulu.w #6,dx -> swap dx             | Y | Y | ? | ! | ! | * |-10
  1089.                 clr.w dx            |   |   |   |   |   |   |
  1090.                 swap dx             |   |   |   |   |   |   |
  1091.                 add.l dx,dx         |   |   |   |   |   |   |
  1092.                 move.l dx,ds        |   |   |   |   |   |   |
  1093.                 add.l ds,dx         |   |   |   |   |   |   |
  1094.                 add.l ds,dx         |   |   |   |   |   |   |
  1095. ------------------------------------+---+---+---+---+---+---+----
  1096. mulu.w #7,dx -> swap dx             | Y | Y | ? | ! | ! | * |-8
  1097.                 clr.w dx            |   |   |   |   |   |   |
  1098.                 swap dx             |   |   |   |   |   |   |
  1099.                 move.l dx,ds        |   |   |   |   |   |   |
  1100.                 asl.l #3,dx         |   |   |   |   |   |   |
  1101.                 sub.l ds,dx         |   |   |   |   |   |   |
  1102. ------------------------------------+---+---+---+---+---+---+----
  1103. mulu.w #9,dx -> swap dx             | Y | Y | ? | ! | ! | * |-8
  1104.                 clr.w dx            |   |   |   |   |   |   |
  1105.                 swap dx             |   |   |   |   |   |   |
  1106.                 move.l dx,ds        |   |   |   |   |   |   |
  1107.                 asl.l #3,dx         |   |   |   |   |   |   |
  1108.                 add.l ds,dx         |   |   |   |   |   |   |
  1109. ------------------------------------+---+---+---+---+---+---+----
  1110. mulu.w #n,dx -> swap dx             | Y | Y | ? | ! | ! | * |-4
  1111.                 clr.w dx            |   |   |   |   |   |   |
  1112.                 swap dx             |   |   |   |   |   |   |
  1113.                 lsl.l #m,dx         |   |   |   |   |   |   |
  1114. ------------------------------------+---+---+---+---+---+---+----
  1115.  n is 2^m, 1 <= m <= 8
  1116. ------------------------------------+---+---+---+---+---+---+----
  1117. mulu.w #n,dx -> swap dx             | Y | Y | ? | ! | ! | * |-2
  1118.                 clr.w dx            |   |   |   |   |   |   |
  1119.                 lsr.l #(16-m),dx    |   |   |   |   |   |   |
  1120. ------------------------------------+---+---+---+---+---+---+----
  1121.  n is 2^m, 8 <= m <= 15
  1122. ------------------------------------+---+---+---+---+---+---+----
  1123. neg.x dx    -> add.x dx,dy          | Y | Y | Y | Y | Y | Y | 2
  1124. sub.x dx,dy                         |   |   |   |   |   |   |
  1125. ------------------------------------+---+---+---+---+---+---+----
  1126.  dx is trashed
  1127. ------------------------------------+---+---+---+---+---+---+----
  1128. neg.x dx    -> eor.x #n-1,dx        | Y | Y | ? | Y | Y | Y | 2
  1129. add.x #n,dx                         |   |   |   |   |   |   |
  1130. ------------------------------------+---+---+---+---+---+---+----
  1131.  n is 2^m, dx<n
  1132. ------------------------------------+---+---+---+---+---+---+----
  1133. neg.x dx    -> sub.x dx,dy          | Y | Y | Y | Y | Y | Y | 2
  1134. add.x dx,dy                         |   |   |   |   |   |   |
  1135. ------------------------------------+---+---+---+---+---+---+----
  1136.  dx is trashed
  1137. ------------------------------------+---+---+---+---+---+---+----
  1138. nop -> (nothing)                    | Y | Y | ? | Y | Y | Y | 2
  1139. ------------------------------------+---+---+---+---+---+---+----
  1140.  remove nops
  1141. ------------------------------------+---+---+---+---+---+---+----
  1142. or.l #n,dx -> bset.l #b,dx          | Y | Y | ? | Y | * | N | 2
  1143. ------------------------------------+---+---+---+---+---+---+----
  1144.  n = 2^b (only 1 bit set)
  1145. ------------------------------------+---+---+---+---+---+---+----
  1146. sub*.x #0,dx -> tst.x dx            | Y | Y | ? | Y | N | N | 2/4
  1147. ------------------------------------+---+---+---+---+---+---+----
  1148. sub.x #n,* -> addq.x #-n,*          | Y | Y | ? | Y | y | N | 2/4
  1149. ------------------------------------+---+---+---+---+---+---+----
  1150.  -8 <= n <= -1
  1151. ------------------------------------+---+---+---+---+---+---+----
  1152. sub.x #n,* -> subq.x #n,*           | Y | Y | ? | Y | y | N | 2/4
  1153. ------------------------------------+---+---+---+---+---+---+----
  1154.  if 1 <= n <= 8
  1155. ------------------------------------+---+---+---+---+---+---+----
  1156. sub.x #n,ax -> lea -n(ax),ax        | Y | Y | ? | Y | y | N | 0/2
  1157. ------------------------------------+---+---+---+---+---+---+----
  1158.  -32767 <= n <= -9, 9 <= n <= 32767
  1159. ------------------------------------+---+---+---+---+---+---+----
  1160. subq.l #n,ax -> subq.w #n,ax        | Y | Y | ? | N | N | N | 0
  1161. ------------------------------------+---+---+---+---+---+---+----
  1162. subq.w #1,dx -> db<cc> dx,??        | y | y | ? |y/*|N/*|y/*|-2
  1163. b<cc> ??        b<cc> ??            |   |   |   |   |   |   |
  1164. ------------------------------------+---+---+---+---+---+---+----
  1165.  if dx=0 then will be slower
  1166. ------------------------------------+---+---+---+---+---+---+----
  1167. subq.w #1,dx -> dbf dx,??           | Y | Y | ? |y/*|N/*|y/*|-2
  1168. bra ??          bra ??              |   |   |   |   |   |   |
  1169. ------------------------------------+---+---+---+---+---+---+----
  1170.  if dx=0 then will be slower
  1171.  
  1172. ---------------------------------------------------------------------------
  1173.                           H I N T S   &   T I P S
  1174. ---------------------------------------------------------------------------
  1175.  
  1176.  
  1177. This new section is for stuff that cannot be included in the above tables.
  1178. This can include pipelining optimizations and other stuff.
  1179.  
  1180. 020+    Sequential memory accesses can cause pipeline stalls, so try and
  1181.         rearrange code so memory accesses do not immediately follow each
  1182.         other.  The same problem occurs if an address register updated
  1183.         in one line is accessed in the next line.
  1184.  
  1185. ALL     Include small routines as macros, because inline routines will
  1186.         be much faster, and in extreme cases smaller.
  1187.  
  1188. ALL     If a subroutine is only called from one position, either move
  1189.         it inline, or only use jmp/bra commands.
  1190.  
  1191. # 7th edition :
  1192.  
  1193. The 020+ hint stated above should only apply to 68020. Since 68030, 68040
  1194. and 68060 have a data cache, sequential memory accesses speed things up.
  1195.  
  1196. ALL    Keep all datas aligned on their respective boundaries : word aligned
  1197.     for words, long-word aligned for long-word.
  1198.  
  1199. ALL    Keep branch target addresses to an even multiple of 8.
  1200.  
  1201. 040+    Don't use FPU registers for temporary values : You should expect
  1202.     rounding problems, and fmove dx,fpx/fmove fpx,dx are slower then
  1203.     move dx,mem/move mem,dx when mem is cached.
  1204.  
  1205. 060    Use mulu.x and muls.x when the factor is not an even multiple of 2.
  1206.     This takes only 2 cycles !
  1207.  
  1208. 030+    Use LSL instead of ASL when possible.
  1209.  
  1210. 020+    Scale factor with indirect addressing modes doesn't add any time
  1211.     penalty.
  1212.  
  1213. 040    Don't use PC indirect addressing modes.
  1214.  
  1215. 040+    Avoid NOP instruction for timing purpose. This takes 8 cycles (040)
  1216.     or 9 cycles (060). On 68040, this instruction also interlocks the
  1217.     effective address calculate and execute stages and synchronizes some
  1218.     portions of the processor before execution. It may have the same
  1219.     side effect on 68060 (I'm not sure about that).
  1220.  
  1221. 040+    Only use move16 on large blocks. It's not really faster than 4
  1222.     successive move, but it bypass the data cache¹ (this avoid multiple
  1223.     reads/writes of cache lines, and keeps the cache valid for further
  1224.     local/global data accesses). Data blocks should be aligned on a
  1225.     16 bytes boundary.
  1226.     ¹ move16 still read/write cached datas.
  1227.  
  1228. 030    B<cc>.s takes less time when the branch is not taken (4 cycles). All
  1229.     other conditions take 6 cycles.
  1230.  
  1231. 040    Branches taken need 2 cycles. Branches not taken need 3 cycles.
  1232.  
  1233. 020+    Avoid bit fields instructions. But some of them may be faster in
  1234.     some rare situations.
  1235.  
  1236. 060    Avoid the use of the same register(s) in two consecutive lines. This
  1237.     may avoid the second instruction to be dispatch in the second
  1238.     pipeline. Only most of the arithmetical/logical instructions, and
  1239.     move from/to registers can be dispatched.
  1240.  
  1241.  
  1242. 030+ Instruction and data cache tips.
  1243. -------------------------------------
  1244.  
  1245. This is a small explanation of how the caches work. This may help you to
  1246. optimize your code to take advantage of these caches.
  1247.  
  1248. These processors always fill their caches on a line basis : They load a
  1249. 16 bytes wide memory block, aligned on a 16 bytes boundary for each
  1250. cache read/write operation. These caches are 4Kb wide (68040) or 8kb
  1251. wide (68060).
  1252. When a cache line read is initiated, the first memory cycle attenmps to load
  1253. the line entry corresponding to the instruction half-line (8 bytes) or data
  1254. item requested by the integer unit. Subsequent transfers are for the
  1255. remaining entries in the cache.
  1256. WriteThrough and CopyBack cache modes work differently when a write occur.
  1257. In WriteThrough mode, the integer unit updates both the cache entry and the
  1258. memory. A write miss never cause a cache line fill.
  1259. In CopyBack mode, the integer unit only refresh the cache entry. The memory
  1260. will be updated when the line will be replace by another line. A write miss
  1261. causes an entire line read, then the corresponding cache entry is updated.
  1262.  
  1263. The 68030 data cache burst mode work as stated above. If the cache burst
  1264. mode is disabled, the 68030 only read/write partial cache lines.
  1265.  
  1266.  
  1267. By now,  we can see that (assuming cache burst mode for the 68030):
  1268. - After a data read operation, subsequent accesses within the same data cache
  1269.   line are faster. The same is true after a write access in CopyBack mode.
  1270.   BTW, these subsequent accesses should be defered to be sure that the entire
  1271.   cache line is ready.
  1272. - Sporadic writes should be done in a WriteThrough memory page to avoid
  1273.   uneeded cache fills. WriteThrough mode can be enable on 040/060 based
  1274.   machines : you have to modify the MMU page descriptors to do so.
  1275. - Keep your local datas together. Doing so, you need less cache lines to
  1276.   cache these datas. i.e., if you read/write the same 4 longwords in a loop,
  1277.   it's better to have them in the same cache line.
  1278. - Keep your functions together too (040/060). Since the MMU is used to select 
  1279.   the cache mode on a page basis, this may avoid uneeded MMU page descriptors
  1280.   fetches. These MMU pages are most often 4Kb wide, aligned on a 4Kb boundary.
  1281. - A linear code may be worst than a loop, due to instruction cache line
  1282.   read timings. As a side note, it may be better to use small slow
  1283.   instructions than large quicker ones. The 68060 can execute an entire
  1284.   instruction cache line in less than 4 cycles, which is not enough to load 
  1285.   the next cache entry : the instruction unit will have to wait for the next
  1286.   instruction !
  1287. - Don't flush the caches all the time. (5394 cycles for the whole data 
  1288.   cache, on 68060, no wait states)
  1289.  
  1290.  
  1291.      
  1292. ---------------------------------------------------------------------------
  1293.                             C O N C L U S I O N
  1294. ---------------------------------------------------------------------------
  1295.  
  1296.  
  1297. There are the optimizations i've come up with so far.  If you could check
  1298. what i've done, and report any errors, that would make this list better.  I
  1299. only have so much time to spend on this, and many hands make light work.
  1300. Also, stats (and more optimizations) for 68020+ CPU's would be welcomed.
  1301. Currently this list is only for simple peephole optimization stuff, but I
  1302. will hopefully get around to more extensive optimizations.  Pipeline
  1303. optimization is on the way, so look out.  Any info on the 68020+ pipelines
  1304. would be appreciated.
  1305.  
  1306. Optimizations with ?question-marks? in the boxes next to them, I do not
  1307. have the data to check yet.
  1308.  
  1309. The latest version of the asp68k archive is available by anonymous ftp from
  1310. ftp.mq.edu.au in the /home/mglew/ directory or by calling Technophilia BBS
  1311. on +61 2 807 3563 (or (02) 807 3563 in Australia).
  1312.  
  1313.  
  1314. ===========================================================================
  1315. EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF
  1316. ===========================================================================
  1317.